home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / HCAL-27 / MOONTRAC.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1997-03-30  |  7.3 KB  |  249 lines

  1. 10   'MOONTRAC - Coordinates of the Moon - 19 MAR 97 rev.30 MAR 97
  2. 20  KEY OFF
  3. 30  IF EX$=""THEN EX$="EXIT"
  4. 40  COLOR 7,0,1
  5. 50  PI=3.14159
  6. 60  P5=2*PI       'Radians per Cycle
  7. 70  D5=360/P5     'Constant for conversion to Degrees
  8. 80  R5=P5/360     'Constant for conversion to Radians
  9. 90  '
  10. 100  '.....start
  11. 110  CLS:COLOR 15,2
  12. 120  PRINT " MOON TRACKER";TAB(55)"by Lance Collister WA1JXN ";
  13. 130  PRINT STRING$(80,32);
  14. 140  LOCATE CSRLIN-1,20:PRINT "edited for HAMCALC by George Murphy VE3ERP"
  15. 150  COLOR 1,0:PRINT STRING$(80,223);:COLOR 7,0
  16. 160  GOSUB 1990    'preface
  17. 170  COLOR 0,7:LOCATE 25,21
  18. 180  PRINT " Press 1 to RUN program or 0 to EXIT....";:COLOR 7,0
  19. 190  Z$=INKEY$:IF Z$=""THEN 190
  20. 200  IF Z$="0"THEN CLS:RUN EX$
  21. 210  IF Z$="1"THEN 230
  22. 220  GOTO 190
  23. 230  VIEW PRINT 4 TO 24:CLS:VIEW PRINT:LOCATE 4
  24. 240  PRINT " ENTER: Your latitude in decimal degrees (+<UNK! {00F8}> if North, -<UNK! {00F8}> if South)";
  25. 250  INPUT L5:L5=L5*R5    'latitude in radians
  26. 260  PRINT " ENTER: Your longitude in decimal degrees (+<UNK! {00F8}> if East, -<UNK! {00F8}> if West) ";
  27. 270  INPUT L6:L6=-L6*R5   'longitude in radians
  28. 280  LTN=INT(L6*180/PI/15)*100   'UTC time adjustment to local time
  29. 290  I=30    'displayed time increment in minutes
  30. 300  I6=90   'maximum elevation to be calculated
  31. 310  INPUT " ENTER: Year (4 digits)...";Y(1)
  32. 320  INPUT " ENTER: Month number......";F(1)
  33. 330  INPUT " ENTER: Day number........";V(1)
  34. 340  N5=1
  35. 350  FOR N=1 TO N5
  36. 360  E1=2400
  37. 370  B=0
  38. 380  Y=Y(N):Y$=STR$(Y):Y$=RIGHT$(Y$,LEN(Y$)-1)
  39. 390  M=F(N):M$=STR$(M):M$=RIGHT$(M$,LEN(M$)-1)
  40. 400  D=V(N):D$=STR$(D):D$=RIGHT$(D$,LEN(D$)-1)
  41. 410  PRINT
  42. 420  CLS
  43. 430  LA=L5*180/PI:LO=L6*180/PI
  44. 440  IF LA<0 THEN LA$="S"ELSE LA$="N"
  45. 450  IF LO<0 THEN LO$="E"ELSE LO$="W"
  46. 460  PRINT " POSITION OF THE MOON on ";Y$;"/";M$;"/";D$;" GMT as seen from";
  47. 470  PRINT USING "####.#<UNK! {00F8}>";LA;:PRINT LA$;
  48. 480  PRINT USING "####.#<UNK! {00F8}>";LO;:PRINT LO$
  49. 490  PRINT STRING$(80,205);
  50. 500  PRINT " LST = Local Solar Time; <UNK! {00F7}>y = yesterday; <UNK! {00F7}>t = tomorrow"
  51. 510  PRINT STRING$(80,205);
  52. 520  PRINT " GMT"TAB(12)"GHA"TAB(20)"DECLIN"TAB(29)"WINDOW"TAB(41)"LST";
  53. 530  PRINT TAB(49)"AZIMUTH"TAB(59)"ELEVATION
  54. 540  PRINT STRING$(67,196);
  55. 550  I1=2
  56. 560  IF M>=3 THEN 640         'Julian Date Calculation
  57. 570  IF INT((Y-1853)/4)<11 THEN 600
  58. 580  C1=-1
  59. 590  GOTO 610
  60. 600  C1=0
  61. 610  J1=365*(Y-1853)+D+30*(M+9)+INT((M+10)/2)
  62. 620  J2=INT((Y-1853)/4)+1+C1
  63. 630  GOTO 750
  64. 640  IF INT((Y-1852)/4)<11 THEN 670
  65. 650  C1=-1
  66. 660  GOTO 680
  67. 670  C1=0
  68. 680  IF M=9 THEN 720
  69. 690  IF M=11 THEN 720
  70. 700  C2=0
  71. 710  GOTO 730
  72. 720  C2=1
  73. 730  J1=365*(Y-1852)+D+30*(M-3)+INT((M-2)/2)
  74. 740  J2=INT((Y-1852)/4)+C1+C2
  75. 750  J=J1+J2                 'Julian Date
  76. 760  T1=J-17472.5
  77. 770  '
  78. 780  '.....compute a row of data
  79. 790  D9=(B-INT(B/100)*100)+INT(B/100)*60
  80. 800  D6=(E1-INT(E1/100)*100)+INT(E1/100)*60
  81. 810  D7=D9-D6
  82. 820  D8=D7-I
  83. 830  IF D7>0 THEN 850
  84. 840  GOTO 870
  85. 850  IF D8>=0 THEN 1940
  86. 860  B=E1
  87. 870  T=(B-INT(B/100)*100)/1440+INT(B/100)/24      'Calc of moon lat and long
  88. 880  T5=T1+T
  89. 890  K1=((0.751213+0.0366011*T5)-INT(0.751213+0.0366011*T5))*P5
  90. 900  K2=((0.822513+0.0362916*T5)-INT(0.822513+0.0362916*T5))*P5
  91. 910  K3=((0.995766+0.00273778*T5)-INT(0.995766+0.00273778*T5))*P5
  92. 920  K4=((0.974271+0.0338632*T5)-INT(0.974271+0.0338632*T5))*P5
  93. 930  K5=((0.0312525+0.0367482*T5)-INT(0.0312525+0.0367482*T5))*P5
  94. 940  L8=K1+0.658*R5*SIN(2*K4)+6.289*R5*SIN(K2)
  95. 950  L8=L8-1.274*R5*SIN(K2-2*K4)-0.186*R5*SIN(K3)
  96. 960  L8=L8+0.214*R5*SIN(2*K2)-0.114*R5*SIN(2*K5)
  97. 970  L8=L8-0.059*R5*SIN(2*K2-2*K4)-0.057*R5*SIN(K2+K3-2*K4)
  98. 980  K6=K5+0.6593*R5*SIN(2*K4)+6.2303*R5*SIN(K2)-1.272*R5*SIN(K2-2*K4)
  99. 990  L7=5.144*R5*SIN(K6)-0.146*R5*SIN(K5-2*K4)
  100. 1000  '.....Calc of right ascension (A=R1) and Declination (D1)
  101. 1010  D1=COS(L7)*SIN(L8)*0.397821+SIN(L7)*0.917463
  102. 1020  D1=ATN(D1/(SQR(1-D1^2)))
  103. 1030  G1=50.5+((D1/0.729))*D5          'Test for start of EUROPEAN window
  104. 1040  G2=80+((D1)/(0.808))*D5          'Test for start AMERICAS end EUROPEAN
  105. 1050  G3=141.5-((D1)*(0.738)*D5)       'Test for start FAR EASTERN end AMERICAS
  106. 1060  G4=170.5-((D1)*(0.857)*D5)   'Test for end of FAR EASTERN window
  107. 1070  A2=COS(L7)*COS(L8)/COS(D1)
  108. 1080  A1=(COS(L7)*SIN(L8)*0.917463-SIN(L7)*0.397821)/COS(D1)
  109. 1090  A=ATN(A1/A2)
  110. 1100  GOSUB 1360
  111. 1110  R1=A
  112. 1120  L1=0.0657098*T1
  113. 1130  L=T*24*1.00274+6.64606+(L1-INT(L1/24)*24)
  114. 1140  L=(L-INT(L/24)*24)
  115. 1150  G=(L/24)*P5-R1 'Calc of Greenwich Hour Angle, G, from local sidereal time
  116. 1160  IF G<P5 THEN 1190
  117. 1170  G=G-P5
  118. 1180  GOTO 1220
  119. 1190  IF G<0 THEN 1210
  120. 1200  GOTO 1220
  121. 1210  G=G+P5
  122. 1220  H=L6-G                  'Calc of your Local Hour Angle, H, from GHA
  123. 1230  E3=COS(L5)*COS(H)*COS(D1)+SIN(D1)*SIN(L5)         'Calc of Elevation, E
  124. 1240  E2=SQR(1-E3^2)
  125. 1250  E=ATN((E3/E2)-(1/(61.33*E2)))
  126. 1260  F=ATN(E3/E2)
  127. 1270  IF E<0 THEN 1890
  128. 1280  IF E>I6*R5 THEN 1890
  129. 1290  A2=SIN(D1)/(COS(L5)*COS(F))               'Calc of Azimuth, A
  130. 1300  A2=A2-(SIN(L5)/COS(L5))*(SIN(F)/COS(F))          'cos AZ
  131. 1310  A1=SIN(L5)*SIN(D1)+COS(L5)*COS(D1)*COS(H)
  132. 1320  A1=(SIN(H)*COS(D1))/SQR(1-A1^2)                  'sin AZ
  133. 1330  A=ATN(A1/A2)                              'azimuth=arctan(sin/cos)
  134. 1340  GOSUB 1360
  135. 1350  GOTO 1510
  136. 1360  IF A=0 THEN 1380 'Begin removal of ambiguities incurred using ATN function
  137. 1370  GOTO 1420
  138. 1380  IF A2<0 THEN 1400
  139. 1390  GOTO 1500
  140. 1400  A=P5/2
  141. 1410  GOTO 1500
  142. 1420  IF A>0 THEN 1480
  143. 1430  IF A2<0 THEN 1460
  144. 1440  A=P5+A
  145. 1450  GOTO 1500
  146. 1460  A=P5+(A-P5/2)
  147. 1470  GOTO 1500
  148. 1480  IF A2>=0 THEN 1500
  149. 1490  A=A+P5/2
  150. 1500  RETURN
  151. 1510  IF (T-11)>(2*I)/1440 THEN 1530
  152. 1520  GOTO 1540
  153. 1530  PRINT
  154. 1540  BS=CINT(B)                  'GMT
  155. 1550  Z1=CINT(A*D5*10)/10         'AZ
  156. 1560  Z2=CINT(E*D5*10)/10         'EL
  157. 1570  Z3=CINT(G*D5*10)/10         'GHA
  158. 1580  Z4=CINT(D1*D5*10)/10        'DEC
  159. 1590  IF Z4<0 THEN 1720           'Begin tests for possible Universal Windows
  160. 1600  IF Z3<G1 THEN 1720
  161. 1610  IF Z3>G2 THEN 1630
  162. 1620  GOTO 1660
  163. 1630  IF Z3<G3 THEN 1680
  164. 1640  IF Z3>G4 THEN 1720
  165. 1650  GOTO 1700
  166. 1660  Y$="European"            'European to Americas window, EU-W
  167. 1670  GOTO 1730
  168. 1680  Y$="Americas"            'Americas universal window, W-W
  169. 1690  GOTO 1730
  170. 1700  Y$="Far East"            'Far Eastern to Americas window, JA-VK-ZL
  171. 1710  GOTO 1730
  172. 1720  Y$=" "
  173. 1730  ES=CINT(B)-LTN           'Local time adjustment
  174. 1740  E$=""
  175. 1750  IF ES<0 THEN ES=ES+2400:E$=" <UNK! {00F7}>y"
  176. 1760  IF ES>2400 THEN ES=ES-2400:E$=" <UNK! {00F7}>t"
  177. 1770  N$="###.#<UNK! {00F8}>"
  178. 1780  BS$=STR$(BS):BS$=RIGHT$(BS$,LEN(BS$)-1)
  179. 1790  IF LEN(BS$)<4 THEN BS$="0"+BS$:GOTO 1790
  180. 1800  ES$=STR$(ES):ES$=RIGHT$(ES$,LEN(ES$)-1)
  181. 1810  IF LEN(ES$)<4 THEN ES$="0"+ES$:GOTO 1810
  182. 1820  ES$=LEFT$(ES$,2)+":"+RIGHT$(ES$,2)
  183. 1830  PRINT TAB(2) BS$;:PRINT TAB(10) USING N$;Z3;:PRINT TAB(20) USING N$;Z4;
  184. 1840  PRINT TAB(28) Y$;:PRINT TAB(40) ES$+E$;:PRINT TAB(50) USING N$;Z1;
  185. 1850  PRINT TAB(60) USING N$;Z2;
  186. 1860  LN=CSRLIN:IF LN<24 THEN PRINT "":GOTO 1880
  187. 1870  GOSUB 2360:CLS
  188. 1880  I1=T
  189. 1890  B=B+I
  190. 1900  Z=(B-INT(B/100)*100)-60
  191. 1910  IF Z<0 THEN 780
  192. 1920  B=INT(B/100)*100+100+Z
  193. 1930  GOTO 780     'compute next row of data
  194. 1940  NEXT N
  195. 1950  PRINT STRING$(67,196)
  196. 1960  N=0
  197. 1970  GOSUB 2360:GOTO 100
  198. 1980  '
  199. 1990  '.....preface
  200. 2000  TB=7
  201. 2010  PRINT TAB(TB);
  202. 2020  PRINT "Displays GHA, Declination, Azimuth and Elevation of the moon from a"
  203. 2030  PRINT TAB(TB);
  204. 2040  PRINT "selected latitude and longitude on a selected date. 'Windows'"
  205. 2050  PRINT TAB(TB);
  206. 2060  PRINT "between the Western Hemisphere and other parts of the world are"
  207. 2070  PRINT TAB(TB);
  208. 2080  PRINT "also indicated where appropriate."
  209. 2090  PRINT
  210. 2100  PRINT TAB(TB);
  211. 2110  PRINT "Position is calculated at 30 minute intervals during the portions"
  212. 2120  PRINT TAB(TB);
  213. 2130  PRINT "of the GMT day when the moon is above the local horizon."
  214. 2140  PRINT
  215. 2150  PRINT TAB(TB);
  216. 2160  PRINT "Latitude and longitude are computed in decimal degrees. If you wish"
  217. 2170  PRINT TAB(TB);
  218. 2180  PRINT "to convert degree/minute/second coordinates to decimal degrees, run"
  219. 2190  PRINT TAB(TB);
  220. 2200  PRINT "the EQUIVALENT VALUES program."
  221. 2210  PRINT
  222. 2220  PRINT TAB(TB);
  223. 2230  PRINT "If you are making a printout, select option (1) from the printer"
  224. 2240  PRINT TAB(TB);
  225. 2250  PRINT "control message bar at the bottom of each screen (i.e., DO NOT"
  226. 2260  PRINT TAB(TB);
  227. 2270  PRINT "advance paper) if you want a single continuous tabular printout."
  228. 2280  PRINT TAB(TB);
  229. 2290  PRINT
  230. 2300  PRINT TAB(TB);
  231. 2310  PRINT "(For further information see the 1997 ARRL HANDBOOK for RADIO"
  232. 2320  PRINT TAB(TB);
  233. 2330  PRINT "AMATEURS, page 23.55).
  234. 2340  RETURN
  235. 2350  '
  236. 2360  'HARDCOPY
  237. 2370  GOSUB 2480:LOCATE 25,2:COLOR 14,6
  238. 2380  PRINT " Press 1 to print screen, 2 to print screen & ";
  239. 2390  PRINT "advance paper, or 3 to continue.";:COLOR 7,0
  240. 2400  Z$=INKEY$:IF Z$="3"THEN GOSUB 2480:RETURN
  241. 2410  IF Z$="1"OR Z$="2"THEN GOSUB 2480:GOTO 2430
  242. 2420  GOTO 2400
  243. 2430  FOR QX=1 TO 24:FOR QY=1 TO 80
  244. 2440  LPRINT CHR$(SCREEN(QX,QY));
  245. 2450  NEXT QY:NEXT QX
  246. 2460  IF Z$="2"THEN LPRINT CHR$(12)
  247. 2470  GOTO 2370
  248. 2480  LOCATE 25,1:PRINT STRING$(80,32);:RETURN
  249.